import {action, observable} from 'mobx';
import api from "../api";
import AnnouncementList from "../views/Web/Announcement/AnnouncementList";


class MobxData {
    // 用户信息
    @observable userInfo: Object = {};
    // 获取用户信息
    @action getUserInfo = async () => {
        const res = await api.getUserInfo();
        this.userInfo = res.data;
    }
    // 修改用户信息
    @action changeUserInfo = (payload: Object) => {
        this.userInfo = payload
    }

    // 学科信息
    @observable subjectList: Array<any> = [];
    // 获取学科信息
    @action getSubjectList = async () => {
        let res = await api.getSubjectList()
        this.subjectList = res.data
    }
    // 修改学科信息
    @action changeSubjectList = (payload: Array<any>) => {
        this.subjectList = payload
    }

    // 班级信息
    @observable classList: Array<any> = [];
    // 获取班级信息
    @action getClassList = async () => {
        let res = await api.getClassList()
        this.classList = res.data
    }
    // 修改班级信息
    @action changeClassList = (payload: Array<any>) => {
        this.classList = payload
    }

    // 项目类别信息
    @observable projectTypeList: Array<any> = [];
    // 获取项目类别信息
    @action getProjectTypeList = async () => {
        let res = await api.getProjectTypeList()
        this.projectTypeList = res.data
    }
    // 修改项目类别信息
    @action changeProjectTypeList = (payload: Array<any>) => {
        this.projectTypeList = payload
    }

    // 公告信息
    @observable announcementList: Array<any> = [];
    // 获取公告信息
    @action getAnnouncementList = async () => {
        let res = await api.getAnnouncementsList()
        this.announcementList = res.data
    }
    // 修改公告信息
    @action changeAnnouncementList = (payload: Array<any>) => {
        this.announcementList = payload
    }

    // 用户列表信息
    @observable userList: Array<any> = [];
    // 获取用户列表信息
    @action getUserList = async () => {
        let res = await api.getUserList()
        this.userList = res.data
    }
    // 修改用户列表信息
    @action changeUserList = (payload: Array<any>) => {
        this.userList = payload
    }

    // 项目列表信息
    @observable projectList: Array<any> = [];
    // 获取项目列表信息
    @action getProjectList = async () => {
        let res = await api.getProjectList()
        this.projectList = res.data
    }
    // 修改项目列表信息
    @action changeProjectList = (payload: Array<any>) => {
        this.projectList = payload
    }

    // 论面试信息
    @observable interviewList: Array<any> = [];
    // 获取论面试信息
    @action getInterviewList = async (data: any) => {
        let res = await api.getInterview(data)
        this.interviewList = res.data
    }
    // 修改论面试信息
    @action changeInterviewList = (payload: any) => {
        this.interviewList = payload
    }
}


export default new MobxData()